<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <p>{{ count }}</p>
      <button @click="fn">btn</button>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          count: 1,
        },
        methods: {
          async fn() {
            // this.count++;
            // // this.$nextTick,里面传入回调函数，表示里面的代码在下一次事件循环里面执行
            // this.$nextTick(() => {
            //   this.count++;

            //   this.$nextTick(() => {
            //     this.count++;
            //   });
            // });

            this.count++;
            await this.$nextTick();
            this.count++;
            await this.$nextTick();
            this.count++;
          },
        },
      });
    </script>
  </body>
</html>
